The present invention relates to a data processing apparatus which executes data processing in accordance with a program including a subroutine call and a return.
Hitherto, when a subroutine call occurs during execution of a program, a parameter for execution of the subroutine or to transfer data from a register to an external memory to keep the data in the register must be read out. For this purpose, a stack area is provided in the external memory, and the data is transferred betweeh the register and the external memory by way of PUSH and POP instructions.
Generally, a PUSH instruction is an instruction to store data in the memory address of the stack area designated by a stack pointer in a central processing unit (CPU), and, thereafter, to change the content of this stack pointer to designate a memory address which is smaller by one block of data. The POP instruction, conversely, is an instruction to change the content of the stack pointer such that the stack pointer designates the memory address which is larger by one block of data, and then to read out the data from the memory address designated as such. Therefore, insofar as data is read out from or written into the external memory by only the PUSH and POP instructions, only the data in the highest order memory address in the stack area is processed. Thus, the data having been saved in this stack area when a subroutine call occurs is retained with certainly.
Ordinarily, a number of registers are included in the CPU. In association with the use of high-level language, the number of data exchanges between the registers and the external memory increases, as does the number of parameters which should be passed or received, so that the number of accesses to the external memory also increases. Further, since it is necessary to receive and pass a plurality of parameters in the stack area in accordance with an arbitrary sequence, calculation of a desired memory address, by adding the address designated by the stack pointer and the offset value, must be performed for each access. The address calculation process, however, takes a very long time and, as such, hinders the overall operating speed of the apparatus.
At present, in spite of the fact that the operating speed of the CPU itself is high, the waiting time of the CPU is prolonged since access time to a large capacity memory is not sufficiently short. Consequently, the overall processing speed is reduced and cannot be improved until access time is reduced.
To reduce the access time and to raise the data processing speed, various conventional methods have been considered.
For example, in a method using a CPU "i80186" made by Intel Co., Ltd. in the U.S.A, data in all registers are written into or read out from the stack area of the external memory by way of a PUSH ALL or a POP ALL instruction. In this method, although it is sufficient to use only a single time of procedure for instruction fetch and interpretation, the next instruction cannot be executed until the data transfer is completed. Therefore, eventually, the total time required to save and restore the data is not reduced much.
A second method uses a CPU "TMS 9900" made by Texas Instruments Co., Ltd. in the U.S.A. This CPU has a work space pointer to designate addresses in all register regions formed in the external memory. According to this method, when a subroutine call or the like occurs, data in the register is not saved in the stack area, but, rather, the content of the work space pointer is merely changed, thereby making it possible to obtain an effect similar to that wherein data in the register is saved in another memory area. Nevertheless, the data processing speed cannot be increased, since it takes a long time to access the register region formed in the external memory.
Further, there is an "RISC" method created by University of California, Berkeley in the U.S.A. According to this method, a number of register groups are provided in the CPU and, by use of these register groups, there is no need to access the external memory when data in the register is saved or parameters are received and passed. Practically speaking, the register groups which can be accessed are limited to execution of a subroutine. These accessible register groups are classified into general purpose registers, registers to receive the parameters and registers to pass the parameters. In the case where a subroutine call occurs, the registers used to pass the parameters in execution of the main routine are used as registers to receive the parameters upon execution of the subroutine. In contrast, the registers used for data reception and for general purpose functions during execution of the main routine are set into an unusable state during execution of the subroutine.
In this "RISC" method, no parameter is transferred at all when the subroutine call occurs so the operation to save data is not needed and a very high-speed subroutine call is realized. However, if a number of subroutine calls occur continuously, it is necessary to transfer a part of the content of the register into the external memory at a certain point in time because there is a limit to the number of register groups available in the CPU. In addition, to reduce the overhead, a very large number of registers, for example, 138 registers, are needed, most of the space of the CPU being occupied by these registers.